package com.xinqi.modules.user.users.user.convert;


import com.xinqi.modules.user.user.domain.UserEntity;
import com.xinqi.modules.user.user.domain.UserExtendEntity;
import com.xinqi.modules.user.user.dto.req.UsersUpdateDTO;
import com.xinqi.modules.user.user.dto.rsp.UserBaseInfoDO;
import com.xinqi.modules.user.user.dto.rsp.UserLoginResultDTO;
import com.xinqi.modules.user.user.dto.rsp.UserPasswordResultDTO;
import com.xinqi.modules.user.user.dto.rsp.UserResultDTO;
import com.xinqi.common.base.user.Account;
import com.xinqi.common.mapstruct.CommonConvertConfig;
import org.mapstruct.Mapper;
import org.mapstruct.MappingTarget;

import java.util.List;

/**
 * 用户信息转换
 *
 * @author: wenjie
 * @date: 2023/05/17
 */
@Mapper(config = CommonConvertConfig.class)
public abstract class UserConvert {
    public abstract Account account(UserEntity s);

    public abstract UserBaseInfoDO userBaseInfo(UserEntity s);

    public abstract List<UserBaseInfoDO> userBaseInfoList(List<UserEntity> list);

    public abstract UserEntity update(UsersUpdateDTO s, @MappingTarget UserEntity t);

    public abstract UserEntity update(UsersUpdateDTO s);

    public abstract UserResultDTO convert(UserEntity s);

    public abstract UserPasswordResultDTO convertPassword(UserEntity s);

    public abstract UserLoginResultDTO convertLogin(UserEntity s);

    public void convertExtend(UserResultDTO userResultDTO, UserExtendEntity extendEntity) {
        userResultDTO.setQrCode(extendEntity.getQrCode());
        userResultDTO.setShowInfoConfig(extendEntity.getShowInfoConfig());
        userResultDTO.setShowMobileConfig(extendEntity.getShowMobileConfig());
        userResultDTO.setSearchPhone(extendEntity.getSearchPhone());
        userResultDTO.setTimes(extendEntity.getTimes());
        userResultDTO.setUserRole(extendEntity.getUserRole());
    }

    public void convertExtend(UserPasswordResultDTO userResultDTO, UserExtendEntity extendEntity) {
        userResultDTO.setQrCode(extendEntity.getQrCode());
        userResultDTO.setShowInfoConfig(extendEntity.getShowInfoConfig());
        userResultDTO.setShowMobileConfig(extendEntity.getShowMobileConfig());
        userResultDTO.setSearchPhone(extendEntity.getSearchPhone());
        userResultDTO.setTimes(extendEntity.getTimes());
        userResultDTO.setUserRole(extendEntity.getUserRole());
    }

}
